package org.agent.aigccore.model.bo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.agent.aigccore.basic.enums.GeneralConfigStatusEnum;
import org.agent.aigccore.basic.serializable.BaseExtInfoBaseDBModel;
import org.agent.aigccore.basic.serializable.CustomConverter;
import org.agent.aigccore.model.dto.GeneralConfigDTO;
import org.agent.aigccore.model.po.GeneralConfigPO;
import org.mapstruct.DecoratedWith;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

/**
 * 通用配置BO类
 */
@Slf4j
@Setter
@Getter
@Schema(description = "通用配置业务对象")
public class GeneralConfigBO extends BaseExtInfoBaseDBModel {

    private String domain;
    private String scene;
    private String ckey;
    private String desc;
    private String value;
    private GeneralConfigStatusEnum status;

    public static final Convert convert = Mappers.getMapper(Convert.class);

    @Mapper(uses = CustomConverter.class)
    @DecoratedWith(AbstractDecoder.class)
    public interface Convert {
        GeneralConfigPO toPO(GeneralConfigBO bo);

        GeneralConfigBO formPO(GeneralConfigPO po);

        GeneralConfigDTO toVO(GeneralConfigBO bo);

        GeneralConfigBO formVO(GeneralConfigDTO vo);
    }

    /**
     * 抽象转换器
     */
    public static abstract class AbstractDecoder implements Convert {
        private final Convert convert;

        public AbstractDecoder(Convert convert) {
            this.convert = convert;
        }
    }
}